#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int score(int arr[][3], int i)
{
    int val = 0;
    if ((arr[i][0]--) > 0 && (arr[i][1]--) > 0 && (arr[i][2]--) > 0)
    {
        val += 2;
    }
    else if ((arr[i][1] -= 2) > 0)
    {
        val++;
    }
    return val;
}

int main() {
    int q = 0;
    scanf("%d", &q);
    int arr[100000][3];
    for (int i = 0; i < q; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    int valr[100000];
    for (int i = 0; i < q; i++)
    {
        valr[i] = score(arr, i);
    }
    for (int i = 0; i < q; i++)
    {
        printf("%d\n", valr[i]);
    }
    return 0;
}